<!-- dynamically determine scripts needed for this config -->
{% assign _scripts = '' | split: '' %}
{% assign _async_marker = 'uswds_async=true' %}
{% assign _site_scripts = site.scripts %}
{% unless _site_scripts -%}
  {% assign _uswds_js = '/assets/uswds/js/uswds.min.js' | append: '?' | append: _async_marker %}
  {% assign _site_scripts = '' | split: '' | push: _uswds_js %}
  {% if site.anchor_js_targets %}
    {% assign _anchor_js = '/assets/js/vendor/anchor.min.js' %}
    {% assign _anchor_conf_js = '/assets/js/anchor.js' %}
    {% assign _site_scripts = _site_scripts
      | push: _anchor_js
      | push: _main_js %}
  {% endif %}
{% endunless %}
{% if site.private_eye %}
  {% assign _pi_js = '/assets/js/vendor/private_eye.js' %}
  {% assign _pi_conf_js = '/assets/js/private_eye_conf.js' %}
  {% assign _site_scripts = _site_scripts
    | push: _pi_js
    | push: _pi_conf_js %}
{% endif %}
{% assign _scripts = _scripts
  | push: _site_scripts
  | push: layout.scripts
  | push: page.scripts
  | uniq %}
{% for _script in _scripts %}
  {% assign _src = _script.src | default: _script %}
    {% if _src %}
      <script src="{{ _src | replace: _async_marker, '' | relative_url }}"{% if _script.async or _src contains _async_marker %} async{% endif %}></script>
    {% endif %}
{% endfor %}


{% if site.search_site_handle %}
<script type="text/javascript">
//<![CDATA[
      var usasearch_config = { siteHandle:"{{ site.search_site_handle }}" };

      var script = document.createElement("script");
      script.type = "text/javascript";
      script.src = "https://search.usa.gov/javascripts/remote.loader.js";
      document.getElementsByTagName("head")[0].appendChild(script);

//]]>
</script>
{% endif %}


{% if site.touchpoints_form_id %}
<script src="https://touchpoints.app.cloud.gov/touchpoints/{{ site.touchpoints_form_id }}.js" async></script>
{% endif %}
